package com.jsmtr.rms.utils;

import java.sql.Date;

import org.springframework.core.convert.converter.Converter;

public class SqlDateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String source) {
        if (source == null) {
            return null;
        }
        source = source.trim();
        if (source.length() == 0) {
            return null;
        }
        Date date = null;
        try {
            date = Date.valueOf(source);
        } catch (Exception e) {
            return null;
        }
        return date;
    }
}